<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>创意时钟</title>
    <link rel="stylesheet" href="./style.css">
</head>
<body>
    <div class="clock">
        <div class="hour">
            <div class="hr"></div>
        </div>
        <div class="min">
            <div class="mn"></div>
        </div>
        <div class="sec">
            <div class="sc"></div>
        </div>
    </div>

    <script type="text/javascript">
        const deg = 6;
        const hr = document.querySelector('.hr');
        const mn = document.querySelector('.mn');
        const sc = document.querySelector('.sc');

        // 定时器
        setInterval(() => {
            // 获取当前系统日期时间
            let day = new Date();
            //获取当前小时数(0-23)
            let hh = day.getHours() * 30;       // 转化为360度
            //获取当前分钟数(0-59)
            let mm = day.getMinutes() * deg;    // 转化为360度
            //获取当前秒数(0-59)  
            let ss = day.getSeconds() * deg;    // 转化为360度

            hr.style.transform = `rotateZ(${(hh) + (mm/12)}deg)`
            mn.style.transform = `rotateZ(${(mm) + (ss/60)}deg)`
            sc.style.transform = `rotateZ(${ss}deg)`

            // console.log(hh + (mm/12))
            // console.log(mm + (ss/60))
            // console.log(ss)
        })
    </script>
</body>
</html>